package com.sk.places.places2.service.entity;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.metamodel.binding.CascadeType;

@Entity
@Table(name="T_PLACE")
public class Place {

	@Id
	private Long id ;
	@Column
	private String name ;
	@Column(name="avg_rating")
	private Integer avgRating ;
	@Column(name="mapinfo_tag")
	private String mapInfoTag ; 
	@OneToOne
	@JoinColumn(name="id", referencedColumnName="place_id", insertable=false, updatable=false) 
	private PlaceFoodLodging placeFoodLodging;  	
	@OneToOne
	@JoinColumn(name="id", referencedColumnName="place_id" ,insertable=false, updatable=false)
	private PlaceTravel placeTravel ;

	
	@ManyToMany
	@JoinTable(name="T_PLACE_PLACE_TYPE", 
	joinColumns=@JoinColumn(name="PLACE_ID",referencedColumnName="ID"), 
		  inverseJoinColumns=@JoinColumn(name="PLACE_TYPE_ID" , referencedColumnName="ID"))
	private List<PlaceType> placeTypes; 
	
	@OneToMany
	(targetEntity=PlacesOnWay.class, mappedBy="place", cascade = javax.persistence.CascadeType.ALL)
	private List<PlacesOnWay> placesOnWay; 

	public List<PlacesOnWay> getPlacesOnWay() {
		return placesOnWay;
	}
	public void setPlacesonWay(List<PlacesOnWay> placesOnWay) {
		this.placesOnWay = placesOnWay;
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Integer getAvgRating() {
		return avgRating;
	}
	public void setAvgRating(Integer avgRating) {
		this.avgRating = avgRating;
	}
	
	public List<PlaceType> getPlaceTypes() {
		return placeTypes;
	}
	public void setPlaceTypes(List<PlaceType> placeTypes) {
		this.placeTypes = placeTypes;
	}
	
	public PlaceTravel getPlaceTravel() {
		return placeTravel;
	}
	public void setPlaceTravel(PlaceTravel placeTravel) {
		this.placeTravel = placeTravel;
	}
	public String getMapInfoTag() {
		return mapInfoTag;
	}
	public void setMapInfoTag(String mapInfoTag) {
		this.mapInfoTag = mapInfoTag;
	}
	public PlaceFoodLodging getPlaceFoodLodging() {
		return placeFoodLodging;
	}
	public void setPlaceFoodLodging(PlaceFoodLodging placeFoodLodging) {
		this.placeFoodLodging = placeFoodLodging;
	}
	@Override
	public String toString() {
		return "Place [id=" + id + ", name=" + name  ; 
				/*", avgRating="
				+ avgRating + ", mapInfoTag=" + mapInfoTag
				+ ", placeFoodLodging=" + placeFoodLodging + ", placeTravel="
				+ placeTravel + ", placeTypes=" + placeTypes + "]"; */
	} 
}
